package api

import (
	"chat3/api/handle"
	"chat3/api/middleware"
	"chat3/consts"
	"github.com/gin-gonic/gin"
	jwt "github.com/golangblogs/gojwt"
)

func Router(r *gin.Engine) {
	r.Use(middleware.Cross())
	user := r.Group("/user")
	{
		user.POST("register", handle.Register)
		user.POST("logon", handle.Logon)
	}
	chat := r.Group("/chat")
	{
		chat.Use(jwt.JWTAuth(consts.JWT_KEY))
		chat.GET("chat", handle.Chat)
		chat.POST("list", handle.List)
	}
	administrators := r.Group("/administrators")
	{
		administrators.GET("chat", handle.AdministratorsChat)
	}

}
